package com.coda.app.mapper;

import com.coda.appVo.room.RoomItemVo;
import com.coda.appVo.room.RoomQueryVo;
import com.coda.entity.RoomInfo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

@Mapper
public interface RoomMapper {
    /**
     * 分页查询房间列表
     * @param roomQueryVo
     * @return
     */
    Page<RoomItemVo> getPage(RoomQueryVo roomQueryVo);

    /**
     * 根据id获取房间信息
     * @return
     */
    @Select("select * from room_info where id = #{id}")
    RoomInfo getRoomInfo(Long id);

    /**
     * 根据公寓id查询房间最小金额
     * @param id
     * @return
     */
    @Select("select min(rent) from room_info where apartment_id = #{id} and is_release = 1")
    BigDecimal getMin(Long id);

    /**
     * 根据公寓id查询房间信息
     * @param id
     * @return
     */
    @Select("select id,room_number,rent from room_info where apartment_id = #{id} and is_release = 1")
    Page<RoomItemVo> getPageByApratId(Long id);

    /**
     * 获取租金
     * @param id
     * @return
     */
    @Select("select rent from room_info where id = #{id}")
    BigDecimal getRent(Long id);
}
